<template>
	<view class="page">
		<view class="card">
			<view class="" v-for="item,index in cardLists" :key="index">
				<view class="card-store" @click="cardBtn(item)">
					<view class="card-left">
						<image :src="item.cover" mode="aspectFill"></image>
						<text class="text" v-if="item.isTransfer==1"> 码头接送</text>
						<text v-else></text>
					</view>
					<view class="card-right">
						<view class="card-title">
							{{item.name}}
						</view>
						<view class="card-text">
							<!-- 暂无 -->
						</view>
						<view class="card-text1">
							<u-tag v-for="ite,ids in item.featureLabelList" :text="ite" type="success" plain size="mini"
								borderColor='#EEEEEE' color='#999999'>
							</u-tag>
						</view>
						<view class="card-price">
							<text v-if='item.bottomPrice !==null'> <text style="font-size: 22rpx;">￥</text>
								{{item.bottomPrice}}
								<text style="font-size: 22rpx; padding: 6rpx;">起</text> </text>
							<text v-else>暂无房间</text>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				FormData: {
					arriveDate: '', //	到达时间(yyyy-MM-dd)
					leaveDate: '', //离开时间(yyyy-MM-dd)
					limit: 4, //每页显示记录数
					page: 1, //当前页码
				},
				cardLists: []

			};
		},

		mounted() {
			this.getDays(0)
			this.getDays(1)
			this.getList()
		},
		methods: {
			getDays(day) {
				var today = new Date();
				var targetday_milliseconds = today.getTime() + 1000 * 60 * 60 * 24 * day;
				today.setTime(targetday_milliseconds); //注意，这行是关键代码
				var tYear = today.getFullYear();
				var tMonth = today.getMonth();
				var tDate = today.getDate();
				var week = today.getDay();
				tMonth = this.doHandleMonth(tMonth + 1);
				tDate = this.doHandleMonth(tDate);
				if (day == 0) {
					this.FormData.arriveDate = tYear + '-' + tMonth + '-' + tDate
				} else if (day == 1) {
					this.FormData.leaveDate = tYear + '-' + tMonth + '-' + tDate
				}
				return tMonth + "月" + tDate + '日'
			},
			doHandleMonth(month) {
				var m = month;
				if (month.toString().length == 1) {
					m = "0" + month;
				}
				return m;
			},
			// 去详情
			cardBtn(item) {
				uni.navigateTo({
					url: "/pagesTrip/hotel/details/index?list=" + JSON.stringify([{
						homestayId: item.id,
						name: item.name,
						...this.FormData,
					}])
				})
			},
			getList() {
				this.$api.get('/api/hotel/getHomestayPage', this.FormData)
					.then(res => {
						this.cardLists = res.data.data.list
					})
			}

		}
	}
</script>

<style lang="scss">
	.page {
		width: 96%;
		box-sizing: border-box;
	}

	.card {
		box-sizing: border-box;
		// padding: 24rpx;

		.card-store {
			box-sizing: border-box;
			// margin: 20rpx 24rpx;
			display: flex;
			background-color: #fff;
			width: 702rpx;
			height: 240rpx;
			border-radius: 10rpx;
			margin-bottom: 20rpx;
			padding-bottom: 20rpx;
			border-bottom: 2rpx solid #EFEFEF;

			.card-left {
				width: 200rpx;
				height: 240rpx;
				position: relative;
				// border-radius: 10rpx 0 0 10rpx;

				image {
					border-radius: 16rpx 0 0 16rpx;
					width: 100%;
					height: 100%;
				}

				.text {
					position: absolute;
					top: 0;
					left: 0;
					font-size: 20rpx;
					color: #FFFFFF;
					background: #FF7D01;
					border-radius: 16rpx 0 18rpx 0;
					padding: 2rpx 3rpx;
				}


			}

			.card-right {
				padding: 24rpx;
				width: 440rpx;

				.card-title {
					font-size: 30rpx;
					color: #111;
				}

				.card-text {
					margin: 12rpx 0;
				}

				.card-text1 {
					padding: 16rpx 0;
					width: 200rpx;
					display: flex;
					justify-content: space-between;


					.text {
						display: block;
						display: flex;
						color: #777777;
						font-size: 24rpx;
						border: 1rpx solid #6e6e6e6e;
					}

				}

				.card-price {
					// padding-top: 30rpx;
					display: flex;
					justify-content: space-between;
					font-size: 38rpx;
					color: #FF4141;
				}
			}
		}
	}
</style>